const fs = require('fs');
const path = require('path');

const appDirectory = fs.realpathSync(process.cwd());
const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);

module.exports = {
  plugins: [
    'autoprefixer',
    'postcss-flexbugs-fixes',
    'postcss-safe-parser',
    [
      'postcss-preset-env',
      {
        autoprefixer: {
          flexbox: 'no-2009',
        },
        stage: 3,
      },
    ],
    [
      'fig-pxtorem',
      {
        rootValue: 37.5,
        selectorBlackList: ['weui', 'mu', 'ant'], // 忽略转换正则匹配项（选择器）
        // unitPrecision: 5,
        // mediaQuery: true,
        // minPixelValue: 0,
        include: [resolveApp('src/ui/styles/h5')],
        propList: [
          '*background*',
          '*padding*',
          '*margin*',
          'letter-spacing',
          'border-radius',
          '*width',
          '*height',
          'left',
          'font*',
          'right',
          'top',
          'bottom',
        ],
      },
    ],
  ],
};
